package ninja9.muzik.dao;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * PlaylistItem entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "playlist_item", catalog = "muzik")
public class PlaylistItem implements java.io.Serializable {

	// Fields

	private PlaylistItemId id;
	private Song song;
	private Playlist playlist;

	// Constructors

	/** default constructor */
	public PlaylistItem() {
	}

	/** full constructor */
	public PlaylistItem(PlaylistItemId id, Song song, Playlist playlist) {
		this.id = id;
		this.song = song;
		this.playlist = playlist;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "playlistId", column = @Column(name = "playlist_id", nullable = false)),
			@AttributeOverride(name = "songId", column = @Column(name = "song_id", nullable = false)) })
	public PlaylistItemId getId() {
		return this.id;
	}

	public void setId(PlaylistItemId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "song_id", nullable = false, insertable = false, updatable = false)
	public Song getSong() {
		return this.song;
	}

	public void setSong(Song song) {
		this.song = song;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "playlist_id", nullable = false, insertable = false, updatable = false)
	public Playlist getPlaylist() {
		return this.playlist;
	}

	public void setPlaylist(Playlist playlist) {
		this.playlist = playlist;
	}

}